home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Game / Thing / CAircraftChinook.as < prev    next >
Encoding:
Text File  |  2011-08-19  |  14.4 KB  |  547 lines

  1.  
  2. {
  3.    if(true)
  4.    {
  5.       CAircraftChinook = ┬º┬ºnewclass(CAircraftChinook,CAircraft);
  6.    }
  7. }
  8.  
  9. package Local.Game.Thing
  10. {
  11.    import Local.Game.World.*;
  12.    import Local.Game.World.Map.*;
  13.    import Local.Game.World.Map.Cell.*;
  14.    import Local.Math.*;
  15.    import STC9.System.*;
  16.    import flash.display.*;
  17.    import flash.events.*;
  18.    import flash.geom.*;
  19.    
  20.    public class CAircraftChinook extends CAircraft
  21.    {
  22.        
  23.       
  24.       public var mCommandFunction:Function;
  25.       
  26.       private var mAltitude:Number;
  27.       
  28.       private var mMinAltitude:Number;
  29.       
  30.       private var mSpawnRateCount:int;
  31.       
  32.       private var mSpawnCount:int;
  33.       
  34.       private var mRearRotor:CThingAnimation;
  35.       
  36.       private var mSpawnRate:int;
  37.       
  38.       private var mCargo:String;
  39.       
  40.       private var mMaxAltitude:Number;
  41.       
  42.       private var mTrackSoundID:String;
  43.       
  44.       private var mMainRotor:CThingAnimation;
  45.       
  46.       private var mSCargo:CThingAnimation;
  47.       
  48.       private var _Command:String;
  49.       
  50.       public function CAircraftChinook(param1:CPosition, param2:String)
  51.       {
  52.          super(param1);
  53.          mCargo = param2;
  54.          mType = "chinook";
  55.          Process = Process_Normal;
  56.          mCommand = "proceed";
  57.          mMaxLife = mLife = 100;
  58.          mMaxSpeed = (18 + Math.random() * 5) * mSpriteScalar;
  59.          mSpeed = 0;
  60.          mAcceleration = 0.6;
  61.          ┬º┬ºpush(┬º┬ºfindproperty(mMaxAltitude));
  62.          ┬º┬ºpush(┬º┬ºfindproperty(mAltitude));
  63.          if(true)
  64.          {
  65.             if(mCargo == "troop")
  66.             {
  67.                addr56:
  68.                ┬º┬ºpush(150);
  69.                if(true)
  70.                {
  71.                }
  72.             }
  73.             else
  74.             {
  75.                ┬º┬ºpush(200);
  76.             }
  77.             ┬º┬ºpop().mMaxAltitude = ┬º┬ºpop().mAltitude = ┬º┬ºpop();
  78.             mMinAltitude = mCargo == "troop" ? 30 : 120;
  79.             mOrientation = 1;
  80.             mDelta = new CPosition(0,0);
  81.             AddThing(mMainRotor = new CThingAnimation(Chinook_MainRotor));
  82.             AddThing(mRearRotor = new CThingAnimation(Chinook_MainRotor));
  83.             if(mCargo == "tank")
  84.             {
  85.                AddThing(mSCargo = new CThingAnimation(Cargo_TankM1A1));
  86.             }
  87.             AddAnimation("stand",Chinook,"AddSprite_Black");
  88.             SetCollisionBySprite(mAnimation[0]);
  89.             AddLoopingSound("flight",Apache_Move);
  90.             mTrackSoundID = PlaySound("flight");
  91.             IncrementBuild();
  92.             SetState("GOTO");
  93.             Process();
  94.             return;
  95.          }
  96.          ┬º┬ºgoto(addr56);
  97.       }
  98.       
  99.       public static function get mCost() : int
  100.       {
  101.          return 25000;
  102.       }
  103.       
  104.       public function get mIconIndex() : int
  105.       {
  106.          return 4;
  107.       }
  108.       
  109.       override public function Dispose() : void
  110.       {
  111.          if(true)
  112.          {
  113.             if(mDisposed)
  114.             {
  115.                if(true)
  116.                {
  117.                   return;
  118.                }
  119.             }
  120.             else
  121.             {
  122.                super.Dispose();
  123.             }
  124.             StopSound(mTrackSoundID);
  125.          }
  126.       }
  127.       
  128.       public function State_MOUSEOVER_Enter() : void
  129.       {
  130.       }
  131.       
  132.       public function get mCommandDrop() : Boolean
  133.       {
  134.          return true;
  135.       }
  136.       
  137.       public function State_DROPTANK_Exit() : void
  138.       {
  139.       }
  140.       
  141.       public function get mCommand() : String
  142.       {
  143.          return _Command;
  144.       }
  145.       
  146.       public function set mCommand(param1:String) : void
  147.       {
  148.          _Command = param1;
  149.          mCommandFunction = this["Command_" + _Command];
  150.       }
  151.       
  152.       public function State_EXIT() : void
  153.       {
  154.          if(true)
  155.          {
  156.             Accelerate_Speed();
  157.             if(true)
  158.             {
  159.                mAngle.mAngle256 = mSpeed / mMaxSpeed * 2 - (mMaxAltitude - mAltitude) / 15;
  160.                if(true)
  161.                {
  162.                   ┬º┬ºpush(┬º┬ºfindproperty(mAltitude));
  163.                   ┬º┬ºpush(mAltitude);
  164.                   if(true)
  165.                   {
  166.                      ┬º┬ºpush(mSpeed / mMaxSpeed);
  167.                      if(true)
  168.                      {
  169.                         ┬º┬ºpush(┬º┬ºpop() * 7);
  170.                      }
  171.                      ┬º┬ºpush(┬º┬ºpop() + ┬º┬ºpop());
  172.                   }
  173.                   ┬º┬ºpop().mAltitude = ┬º┬ºpop();
  174.                   _Move();
  175.                }
  176.                if(mAltitude > 500)
  177.                {
  178.                }
  179.                ┬º┬ºgoto(addr64);
  180.             }
  181.             Dispose();
  182.          }
  183.          addr64:
  184.       }
  185.       
  186.       public function State_GOTO_Exit() : void
  187.       {
  188.       }
  189.       
  190.       public function State_MOUSEOVER_Exit() : void
  191.       {
  192.       }
  193.       
  194.       public function State_GOTO() : void
  195.       {
  196.          mCommandFunction();
  197.       }
  198.       
  199.       public function State_MOUSEOVER() : void
  200.       {
  201.          ┬º┬ºpush(mStateCount < 0);
  202.          if(true)
  203.          {
  204.             ┬º┬ºpush(┬º┬ºpop() && !mMouseOver);
  205.          }
  206.          if(┬º┬ºpop())
  207.          {
  208.             SetState(mReturnStateID);
  209.          }
  210.       }
  211.       
  212.       public function State_DROPTANK() : void
  213.       {
  214.          var _loc1_:Point = null;
  215.          if(!mSCargo)
  216.          {
  217.             return;
  218.          }
  219.          mSCargo.mInvisible = true;
  220.          _loc1_ = OrientatePoint(mSCargo.mSprite.mObjects["create"].mPosition.clone(),mSCargo.mPosition);
  221.          mLevel.AddFriend(new CVehicleTankM1A1(new CPosition(_loc1_.x,_loc1_.y)));
  222.          mSCargo = null;
  223.          SetState("EXIT");
  224.       }
  225.       
  226.       public function State_LANDTANK_Exit() : void
  227.       {
  228.       }
  229.       
  230.       public function get mLongName() : String
  231.       {
  232.          return "CHINOOK TRANSPORT HELICOPTER";
  233.       }
  234.       
  235.       public function get mCommandProceed() : Boolean
  236.       {
  237.          return true;
  238.       }
  239.       
  240.       override public function Explode(param1:Point = null) : void
  241.       {
  242.          super.Explode(param1);
  243.          State_DROPTANK();
  244.       }
  245.       
  246.       private function _Move() : void
  247.       {
  248.          var _loc1_:Number = NaN;
  249.          if(mSpeed)
  250.          {
  251.             mDelta.Copy(CPosition.NORMALIZE(mAngle.mDelta,mSpeed));
  252.             mPosition.Add(mDelta);
  253.             _loc1_ = Math.min(50,mAltitude / 2);
  254.             mPosition.y = (GetAltitude(mPosition.x - _loc1_) + GetAltitude(mPosition.x + _loc1_)) / 2 - mAltitude;
  255.             if(MapMove())
  256.             {
  257.                Process_ReachedObjective();
  258.             }
  259.             mCollide.Update();
  260.          }
  261.       }
  262.       
  263.       public function State_LANDTROOP_Enter() : void
  264.       {
  265.       }
  266.       
  267.       public function Command_halt() : void
  268.       {
  269.          if(true)
  270.          {
  271.             Deaccelerate_Speed(0.1);
  272.             if(true)
  273.             {
  274.                mAngle.mAngle256 = mSpeed / mMaxSpeed * 2;
  275.             }
  276.             _Move();
  277.          }
  278.       }
  279.       
  280.       public function State_EXIT_Enter() : void
  281.       {
  282.       }
  283.       
  284.       public function State_LANDTANK_Enter() : void
  285.       {
  286.       }
  287.       
  288.       public function State_DROPTANK_Enter() : void
  289.       {
  290.       }
  291.       
  292.       public function get mShortDesc() : String
  293.       {
  294.          return "The Chinook is a twin-engine, tandem rotor heavy-lift helicopter. Capable of bringing troops and a tank to the frontline. Has no attack capabilities!";
  295.       }
  296.       
  297.       public function State_DROPTROOP_Enter() : void
  298.       {
  299.       }
  300.       
  301.       public function State_DROPTROOP() : void
  302.       {
  303.          var _loc1_:Point = null;
  304.          if(true)
  305.          {
  306.             var _loc3_:*;
  307.             var _loc2_:*;
  308.             ┬º┬ºpush(_loc3_ = (_loc2_ = ┬º┬ºfindproperty(mSpawnRateCount)).mSpawnRateCount + 1);
  309.             if(true)
  310.             {
  311.                _loc2_.mSpawnRateCount = _loc3_;
  312.             }
  313.             if(┬º┬ºpop() > mSpawnRate)
  314.             {
  315.                mSpawnRateCount = 0;
  316.                _loc1_ = OrientatePoint(mSprite.mObjects["drop"].mPosition.clone(),mPosition);
  317.                mLevel.AddFriend(new CPeepM16(new CPosition(_loc1_.x,_loc1_.y)));
  318.                addr33:
  319.                ┬º┬ºpush((_loc2_ = ┬º┬ºfindproperty(mSpawnCount)).mSpawnCount);
  320.                if(true)
  321.                {
  322.                   ┬º┬ºpush(_loc3_ = ┬º┬ºpop() - 1);
  323.                   if(true)
  324.                   {
  325.                      _loc2_.mSpawnCount = _loc3_;
  326.                   }
  327.                }
  328.                if(┬º┬ºpop() <= 0)
  329.                {
  330.                   SetState("EXIT");
  331.                }
  332.             }
  333.             return;
  334.          }
  335.          ┬º┬ºgoto(addr33);
  336.       }
  337.       
  338.       public function State_GOTO_Enter() : void
  339.       {
  340.          if(true)
  341.          {
  342.             mSpeed = 0;
  343.          }
  344.       }
  345.       
  346.       public function State_LANDTANK() : void
  347.       {
  348.          if(true)
  349.          {
  350.             Deaccelerate_Speed(0.03);
  351.             if(true)
  352.             {
  353.                mAngle.mAngleRAD = (mSpeed / mMaxSpeed * 2 - (mMaxAltitude - mAltitude) / 50) * Math.PI / 128;
  354.                if(true)
  355.                {
  356.                   ┬º┬ºpush(┬º┬ºfindproperty(mAltitude));
  357.                   ┬º┬ºpush(mSpeed / mMaxSpeed);
  358.                   ┬º┬ºpush(mMaxAltitude);
  359.                   if(true)
  360.                   {
  361.                      ┬º┬ºpush(┬º┬ºpop() * (┬º┬ºpop() - mMinAltitude));
  362.                      ┬º┬ºpush(mMinAltitude);
  363.                   }
  364.                   ┬º┬ºpop().mAltitude = ┬º┬ºpop() + ┬º┬ºpop();
  365.                   _Move2();
  366.                }
  367.                if(Math.abs(mAltitude - mMinAltitude) <= 1)
  368.                {
  369.                }
  370.                ┬º┬ºgoto(addr75);
  371.             }
  372.             SetState("DROPTANK");
  373.          }
  374.          addr75:
  375.       }
  376.       
  377.       override public function Draw() : void
  378.       {
  379.          var _loc1_:Matrix = null;
  380.          var _loc2_:Point = null;
  381.          super.Draw();
  382.          _loc1_ = GetOrientationMatrix();
  383.          if(true)
  384.          {
  385.             DrawSprite(_loc1_);
  386.          }
  387.          _loc2_ = _loc1_.transformPoint(mSprite.mObjects["mainrotor"].mPosition);
  388.          if(true)
  389.          {
  390.             ┬º┬ºpush(mMainRotor);
  391.             if(true)
  392.             {
  393.                ┬º┬ºpop().mPosition.SetXY(_loc2_.x + mPosition.x,_loc2_.y + mPosition.y);
  394.                if(true)
  395.                {
  396.                   mMainRotor.mAngle.mAngle = mAngle.mAngle / 3;
  397.                }
  398.                ┬º┬ºpush(mMainRotor);
  399.             }
  400.             ┬º┬ºpop().Draw();
  401.          }
  402.          _loc2_ = _loc1_.transformPoint(mSprite.mObjects["rearrotor"].mPosition);
  403.          mRearRotor.mPosition.SetXY(_loc2_.x + mPosition.x,_loc2_.y + mPosition.y);
  404.          mRearRotor.mAngle.mAngle = mAngle.mAngle / 3;
  405.          mRearRotor.Draw();
  406.          if(mSCargo)
  407.          {
  408.             mSCargo.Draw();
  409.          }
  410.       }
  411.       
  412.       public function State_EXIT_Exit() : void
  413.       {
  414.       }
  415.       
  416.       private function _Move2() : void
  417.       {
  418.          var _loc1_:Number = NaN;
  419.          var _loc2_:Point = null;
  420.          if(true)
  421.          {
  422.             if(mSpeed)
  423.             {
  424.                if(true)
  425.                {
  426.                   mDelta.Copy(CPosition.NORMALIZE(mAngle.mDelta,mSpeed));
  427.                   if(true)
  428.                   {
  429.                      mPosition.Add(mDelta);
  430.                   }
  431.                   _loc1_ = Math.min(50,mAltitude / 2);
  432.                }
  433.                mPosition.y = (GetAltitude(mPosition.x - _loc1_) + GetAltitude(mPosition.x + _loc1_)) / 2 - mAltitude;
  434.                addr66:
  435.                _loc2_ = OrientatePoint(mSprite.mObjects["drop"].mPosition.clone(),mPosition);
  436.                if(_loc2_.y < 0)
  437.                {
  438.                   mPosition.y = mMinAltitude + (mPosition.y - _loc2_.y);
  439.                }
  440.                if(MapMove())
  441.                {
  442.                   Process_ReachedObjective();
  443.                }
  444.                mCollide.Update();
  445.             }
  446.             return;
  447.          }
  448.          ┬º┬ºgoto(addr66);
  449.       }
  450.       
  451.       public function Command_drop() : void
  452.       {
  453.          ┬º┬ºpush(┬º┬ºfindproperty(SetState));
  454.          if(true)
  455.          {
  456.             ┬º┬ºpop().SetState(mCargo == "troop" ? "LANDTROOP" : "LANDTANK");
  457.             return;
  458.          }
  459.          ┬º┬ºgoto(addr15);
  460.       }
  461.       
  462.       public function get mCommandHalt() : Boolean
  463.       {
  464.          return false;
  465.       }
  466.       
  467.       override public function get mSmallPrize() : int
  468.       {
  469.          return mCost;
  470.       }
  471.       
  472.       public function Command_proceed() : void
  473.       {
  474.          if(true)
  475.          {
  476.             Accelerate_Speed();
  477.             if(true)
  478.             {
  479.                mAngle.mAngle256 = mSpeed / mMaxSpeed * 2;
  480.             }
  481.             _Move();
  482.          }
  483.       }
  484.       
  485.       override public function get mPrize() : int
  486.       {
  487.          return mCost * 2;
  488.       }
  489.       
  490.       public function Process_Normal() : void
  491.       {
  492.          if(Process_State != null)
  493.          {
  494.             Process_State();
  495.          }
  496.          if(mDisposed)
  497.          {
  498.             return;
  499.          }
  500.          if(mSCargo)
  501.          {
  502.             mSCargo.mPosition.Copy(OrientatePoint(mSprite.mObjects["rope"].mPosition.clone(),mPosition));
  503.          }
  504.          Process_Children();
  505.          if(mDead)
  506.          {
  507.             State_DROPTANK();
  508.             DispatchDispose();
  509.          }
  510.       }
  511.       
  512.       public function State_LANDTROOP() : void
  513.       {
  514.          Deaccelerate_Speed(0.025);
  515.          mAngle.mAngleRAD = (mSpeed / mMaxSpeed * 2 - (mMaxAltitude - mAltitude) / 15) * Math.PI / 128;
  516.          ┬º┬ºpush(┬º┬ºfindproperty(mAltitude));
  517.          ┬º┬ºpush(mSpeed / mMaxSpeed);
  518.          if(true)
  519.          {
  520.             ┬º┬ºpush(┬º┬ºpop() * (mMaxAltitude - mMinAltitude) + mMinAltitude);
  521.          }
  522.          ┬º┬ºpop().mAltitude = ┬º┬ºpop();
  523.          _Move2();
  524.          if(Math.abs(mAltitude - mMinAltitude) <= 1)
  525.          {
  526.             SetState("DROPTROOP");
  527.             mSpawnRate = 10;
  528.             mSpawnRateCount = 0;
  529.             mSpawnCount = 10;
  530.          }
  531.       }
  532.       
  533.       public function get mCommandTakeControl() : Boolean
  534.       {
  535.          return false;
  536.       }
  537.       
  538.       public function State_LANDTROOP_Exit() : void
  539.       {
  540.       }
  541.       
  542.       public function State_DROPTROOP_Exit() : void
  543.       {
  544.       }
  545.    }
  546. }
  547.